package sort;

import java.util.Random;

public class SortTest {
	public static void main(String[] args) {
		int[] list = generateRandArray(1000000, 1000000);
		
		int run = 0b1101110000;

		if((run&1) == 1) System.out.println("AshSort: " + AshSort.Sort(list.clone()) + "ms");
		if((run&2) == 2) System.out.println("Insertion Sort: " + InsertionSort.Sort(list.clone()) + "ms");
		if((run&4) == 4) System.out.println("Bucket Sort: " + BucketSort.Sort(list.clone()) + "ms"); 
		if((run&8) == 8) System.out.println("Merge Sort: " + MergeSort.Sort(list.clone()) + "ms");
		if((run&16) == 16) System.out.println("Heap Sort (In place): " + HeapSortInPlace.Sort(list.clone()) + "ms");
		if((run&32) == 32) System.out.println("Heap Sort: " + HeapSort.Sort(list.clone()) + "ms");
		if((run&64) == 64) System.out.println("Quick Sort: " + QuickSort.Sort(list.clone()) + "ms");
		if((run&126) == 128) System.out.println("Bucket Sort (Limon): " + BucketSortLimon.Sort(list.clone()) + "ms"); 
		if((run&256) == 256) System.out.println("AshSortPlus: " + AshSortPlus.Sort(list.clone()) + "ms");
		if((run&512) == 512) System.out.println("Counting Sort: " + CountingSort.Sort(list.clone()) + "ms");
	}

	public static void shiftAndInsert(int[] list, int insertElement, int insertPosition){
		if(insertElement == insertPosition) return;
		//Moving all elements of the array up by one
		int tempEntry = list[insertElement], k=insertElement;
		for(; k>insertPosition; k--) list[k] = list[k-1]; 
		
		list[insertPosition] = tempEntry;//insertion step
	}
	
	public static void swap(int[] list, int posA, int posB) {
		int temp = list[posA];
		list[posA] = list[posB];
		list[posB] = temp;
	}
	
	public static int[] generateRandArray(int range, int size){
		int[] array = new int[size];
		
		Random rnd = new Random();
		for(int i=0; i<size; i++) array[i] = rnd.nextInt(range);
		
		return array;
	}
}
